package com.code.helper;

import com.common.config.ProjectConfig;

import java.io.File;

public class ProjectHelper {
    public static String getBaseCodePath(ProjectConfig projectConfig, String path) {
        String projectPath = projectConfig.getProjectPath();
        String projectName = projectConfig.getProjectName();
        String packageName = projectConfig.getPackageName();
        StringBuilder builder = new StringBuilder();
        builder.append(projectPath);
        if (!projectPath.endsWith("/")) {
            builder.append(File.separator);
        }
        builder.append(projectName).append(File.separator);
        builder.append("src/main/java/");
        String packagePath = packageName.replaceAll("\\.", "/");
        builder.append(packagePath);
        builder.append(File.separator);
        builder.append(path);
        return builder.toString();
    }

    public static String getBaseCodePackage(ProjectConfig projectConfig, String path) {

        String packageName = projectConfig.getPackageName();
        return packageName + "." + path.replaceAll("/",".");
    }
}
